<%--
  Created by IntelliJ IDEA.
  User: zeng
  Date: 2016/8/16
  Time: 16:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>局长信箱</title>
    <link type="text/css" href="<c:url value='/resource/wx/newcss/common.css'/>" rel="stylesheet"/>
    <link rel="stylesheet" href="<c:url value='/resource/wechat/newcss/frozen.css'/>">
    <link rel="stylesheet" type="text/css" href="<c:url value='/resource/wechat/newcss/main.css'/>"/>
    <script type="text/javascript" src="<c:url value='/resource/wx/js/jquery-2.1.1.min.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/resource/wx/newjs/common.js'/>"></script>
    <script type="text/javascript" src="<c:url value="/resource/js/jweixin-1.1.0.js"></c:url>"></script>
    <style type="text/css">
        .ui-radio input {
            width: 15px;
        }

        .ui-radio {
            margin-right: 15px;
            width: auto;
        }

        @media screen and (max-width: 435px) {
            .ui-radio {
                margin-right: 15px;
                width: 33%;
            }

            .ui-form-item {
                height: auto;
            }
        }
    </style>
</head>

<script type="text/javascript">
    $(function () {

        $('#save').click(function () {
            var xm = $('#xm').val();
            var date = $('#date').val();
            var sjhm = $('#sjhm').val();
            var slbh = $('#slbh').val();
            var tsbt = $('#tsbt').val();
            var tsnr = $('#tsnr').val();
            var infotype = $('#infotype').val();
            var lx = '';
            var temp1 = $("#idCard").val();
            var temp2 = $("#email").val();
            var temp3 = $("#postCode").val();
            var temp4 = $("#address").val();
            var re = /^[1-9][0-9]{5}$/;
//            var ts = document.getElementById('ts').checked;
//            var zx = document.getElementById('zx').checked;
//            var jy = document.getElementById('jy').checked;
//            var by = document.getElementById('by').checked;
//
//            if(ts == true){
//                lx = '1';
//            }
//            if(zx == true){
//                lx = '2';
//            }
//            if(jy == true){
//                lx = '3';
//            }
//            if(by == true){
//                lx = '4';
//            }
            if (xm == '') {
                toast("请输入姓名");
                return false;
            }
            if (temp2 != '' && !temp2.match(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/)) {
                toast("请输入正确的邮箱格式！");
                $("#email").focus();
                return false;
            }
            if (temp3 != '' && !re.test(temp3)) {
                toast("请输入正确的邮编！")
                return false;
            }
            if (infotype == '请选择') {
                toast('请选择类别');
                return false;
            }
            if (tsbt == '') {
                toast("请输入标题");
                return false;
            }
            if (tsnr == '') {
                toast("请输入内容");
                return false;
            }
            var arr2 = date.split("/");
            var date2 = new Date(arr2[0],parseInt(arr2[1])-1,arr2[2]);
            var data = {
                'xjusername': xm,
                'xjuserphone': sjhm,
                'xjno': slbh,
                'xjtype': infotype,
                'xjtitle': tsbt,
                'xjcontent': tsnr,
                'lx': '1',
                'ly': '${ly}',
                'xjuserguid': '${userGuid}',
                'xjdate': date2,
                'temp1': temp1,
                'temp2': temp2,
                'temp3': temp3,
                'temp4': temp4
            };

            $.ajax({
                type: "POST",
                url: "<c:url value='/weixinquery/savetsjyjzxx'/>",
                data: JSON.stringify(data),
                contentType: "application/json;charset=utf-8",
                async: false,
                dataType: "json",
                success: function (data) {
                    if (data.succ == true) {
                        toast("提交成功！");
                        setTimeout(function () {
                            <%--window.location.href = "<c:url value='/weixinquery/tsjyym'/>";--%>
//                          提交成功后 灰化按钮
                            $("#save").attr("disabled", "disabled");
                            $("#save").css("background-color", "#DDDDDD");
                            var ua = navigator.userAgent.toLowerCase();
                            if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                                window.location.href = "http://gawx.daqing.gov.cn/econsole/weixin/wx_member/baseOauth?url=http://gawx.daqing.gov.cn/econsole/weixin/wx_member/index";
                            }
                          else {
                                    if (/iphone|ipad|ipod/.test(ua)) {
                                    suisp();
                                    } else if (/android/.test(ua)) {
                                        //APP局长信箱提交返回首页
                                        window.webdemo.suisp();
                                    }
                           }
                        }, 1000);
                    } else {
                        toast("提交失败！");
                        $("#resultmsg").html(data.msg);
                        return false;
                    }
                }
            });

        });
    });


</script>

<body ontouchstart>
<%--<header class="ui-header ui-header-positive ui-border-b">
    <i class="ui-icon-return" onclick="history.back()"></i>
    <h1>投诉建议</h1>
</header>--%>
<section class="ui-container">

    <%--<h1 class="jzxx_tit">局长信箱</h1>--%>

    <div style="clear: both;"></div>

    <div class="demo-item">
        <div class="demo-block">
            <div class="ui-form ui-border-t">
                <form action="#">
                    <input type="hidden" id="p" value="${p}"/>
                    <input type="hidden" id="slbh" value="${slbh}">
                    <div class="ui-form-item ui-border-b">
                        <label>
                            <span class="t_red">*</span>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：
                        </label>
                        <input id="xm" type="text" value="${aliasName}" placeholder="" maxlength="20"/>
                    </div>
                    <div class="ui-form-item ui-border-b">
                        <label>
                            <span class="t_red">&nbsp;</span>时&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;间：
                        </label>
                        <input id="date" type="text" placeholder=""
                               value="<fmt:formatDate value="${today}" pattern="yyyy/MM/dd"/>" readonly="readonly"/>
                    </div>
                    <div class="ui-form-item ui-border-b">
                        <label>
                            <span class="t_red">*</span>手机号码：
                        </label>
                        <input id="sjhm" type="text" placeholder="" name="telephone" value="${telephone}"
                               readonly="readonly"/>
                    </div>
                    <div class="ui-form-item ui-border-b">
                        <label>
                            <span class="t_red">&nbsp;</span>身份证号：
                        </label>
                        <input id="idCard" type="text" placeholder="" name="idCard" value="${idCard}"
                               readonly="readonly"/>
                    </div>
                    <div class="ui-form-item ui-border-b">
                        <label>
                            <span class="t_red">&nbsp;</span>&nbsp;&nbsp;E-Mail&nbsp;&nbsp;：
                        </label>
                        <input id="email" type="text" placeholder="" name="email" value="" maxlength="20"/>
                    </div>
                    <div class="ui-form-item ui-border-b">
                        <label>
                            <span class="t_red">&nbsp;</span>邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;编：
                        </label>
                        <input id="postCode" type="text" placeholder="" name="postCode" value="" maxlength="6"/>
                    </div>
                    <div class="ui-form-item ui-border-b">
                        <label>
                            <span class="t_red">&nbsp;</span>地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址：
                        </label>
                        <input id="address" type="text" placeholder="" name="address" value="" maxlength="50"/>
                    </div>
                    <div class="ui-form-item ui-border-b">
                        <%--<label>--%>
                        <%--<span class="t_red">*</span>类型：--%>
                        <%--</label>--%>

                        <%--<div style="position: relative; left:100px;">--%>
                        <%--<label class="ui-radio" for="radio">--%>
                        <%--<input id="ts" type="radio" checked="checked" name="radio" />--%>
                        <%--<span>投诉</span>--%>
                        <%--</label>--%>


                        <%--<label class="ui-radio" for="radio">--%>
                        <%--<input id="zx" type="radio" name="radio" />--%>
                        <%--<span>咨询</span>--%>
                        <%--</label>--%>


                        <%--<label class="ui-radio" for="radio">--%>
                        <%--<input id="jy" type="radio" name="radio" />--%>
                        <%--<span>建议</span>--%>
                        <%--</label>--%>


                        <%--<label class="ui-radio" for="radio">--%>
                        <%--<input id="by" type="radio" name="radio" />--%>
                        <%--<span>表扬</span>--%>
                        <%--</label>--%>
                        <span class="t_red">*</span>类&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：
                        <select id="infotype" name="infotype" onchange="">
                            <option>请选择</option>
                            <option value="1">线索举报</option>
                            <option value="2">意见建议</option>
                            <option value="3">求助咨询</option>
                            <option value="4">其他</option>
                        </select>

                    </div>
                    <div class="ui-form-item ui-border-b">
                        <label>
                            <span class="t_red">*</span>标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题：
                        </label>
                        <input id="tsbt" type="text" placeholder="" value="" maxlength="100"/>
                    </div>
                    <div class="ui-form-item ui-form-item-textarea ui-border-b">
                        <label>
                            <span class="t_red">*</span>内&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;容：
                        </label>
                        <textarea id="tsnr" placeholder="" maxlength="500"></textarea>
                    </div>
            </div>
            </form>
        </div>
    </div>
    </div>

    <div class="ui-btn-wrap">
        <button id="save" class="ui-btn-lg ui-btn-primary">
            提交
        </button>
    </div>
    <div id="resultmsg"></div>
</section>
</body>
</html>
